package com.woniuxy.carlife.carlifeuserweb.controller;


import cn.hutool.core.util.ObjectUtil;
import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.Result;
import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.StatusCode;
import com.woniuxy.carlife.carlifecommonsweb.util.CopyUtil;
import com.woniuxy.carlife.carlifecommonsweb.util.JwtUtil;
import com.woniuxy.carlife.carlifeusermodel.dto.CardisplacementDto;
import com.woniuxy.carlife.carlifeusermodel.dto.CaryearsDto;
import com.woniuxy.carlife.carlifeuserweb.entity.Caryears;
import com.woniuxy.carlife.carlifeuserweb.service.CaryearsService;
import com.woniuxy.carlife.carlifeuserweb.util.StatusMessageEnum;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjq
 * @ClassName:CaryearsController
 * @Description:查询汽车年份
 * @date 2021/4/6 20:02
 **/

//@RestController
//@RequestMapping("/caryears")
//@Api(tags = "查询汽车年份")//用于描述接口类的相关信息，作用于类上

public class CaryearsController {

    @Resource
    CaryearsService caryearsService;

//    /*
//     * 功能描述〈查询所有汽车年份〉
//     * @author:zjq
//     * @param:
//     * @return:
//     * @Date 2021/4/11 22:27
//     * @throws
//     */
//
//    @ApiOperation(value = "查询所有汽车年份")
//    @GetMapping("/ordinary/findCaryears")
//    public Result findCaryears()  {
//        ServletRequestAttributes sra =
//                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        String token = sra.getRequest().getHeader("token");
//        JwtUtil jwtUtil = new JwtUtil();
//        Claims claims = jwtUtil.parseTokenOrdinary(token);
//        if (claims == null) {
//
//            return new Result(false, StatusCode.ERROR, StatusMessageEnum.NOT_LOGGED_IN.toString());
//        }
//        List<Caryears> caryears = caryearsService.findCaryears();
//        if (ObjectUtil.isNull(caryears)) {
//            return new Result(false, StatusCode.ERROR, StatusMessageEnum.QUERY_IS_EMPTY.toString());
//        }
//
//        List<CaryearsDto> caryearsList = CopyUtil.getList(caryears, CaryearsDto.class);
//
//        return new Result(true, StatusCode.OK, StatusMessageEnum.SEARCH_SUCCESSFUL.toString(), caryearsList);
//
//    }

}

